<template>
	<view>
		<view class="scroll-view_H charts-tabbar">
			<!-- <block v-for="(item, index) in tab"> -->
				<view class="boxItem left" :class="{ active: 0 == curr }" @click="tabChange(0)">{{ tab[0] }}</view>
				<view class="boxItem right" :class="{ active: 1 == curr }" @click="tabChange(1)">{{ tab[1] }}</view>
			<!-- </block> -->
		</view>
	</view>
</template>

<script>
export default {
	name: 'scroll-bar3',
	props: {
		tab: {
			type: Array,
			default: [],
		}
	},
	data() {
		return {
			curr: 0
		};
	},
	methods: {
		tabChange(index) {
			if (index == this.curr) return;

			this.curr = index;
			this.$emit('change', index + 1);
		}
	}
};
</script>

<style lang="scss">
.scroll-view_H {
}

.charts-tabbar {
	overflow: hidden;
	background: rgba(236, 236, 236, 0);
	// border: 1px solid #d5d5d5;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	flex-wrap: nowrap;
	.boxItem {
		flex: 1;
		width: 50%;
		min-height: 70rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
		box-sizing: border-box;
		font-size: 28rpx;
		font-weight: bold;
		color: #333333;
		&.left{
			border-top: 1px solid #d5d5d5;
			border-bottom: 1px solid #d5d5d5;
			border-left: 1px solid #d5d5d5;
			border-radius:   12px 0 0 12px;
		}
		&.right{
			border-top: 1px solid #d5d5d5;
			border-bottom: 1px solid #d5d5d5;
			border-right: 1px solid #d5d5d5;
			border-radius:   0 12px 12px 0;
		}
		&.active {
			color: #fff;
			background: #00a0e9;
			border-color: #00a0e9;
		}
	}
}
</style>
